package com.yuncheng.mcp.service.impl;

import com.yuncheng.mcp.service.DateTimeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @title: DateTimeService
 * @Author: Liuxk
 * @Date: 2025/5/22 15:25
 */


@Service
public class DateTimeServiceImpl implements DateTimeService {

    private static final Logger log = LoggerFactory.getLogger(DateTimeServiceImpl.class);


    @Tool(description = "获取用户所在时区的当前日期和时间")
    public String getCurrentDateTime() {
        log.info("==========获取当前时间========");
        return LocalDateTime.now().atZone(LocaleContextHolder.getTimeZone().toZoneId()).toString();
    }

    @Tool(description = "为指定时间设置用户闹钟，时间以ISO-8601格式提供")
    public String setAlarm(String time) {
        LocalDateTime alarmTime = LocalDateTime.parse(time, DateTimeFormatter.ISO_DATE_TIME);
        log.info("==========闹钟设置为 ： {}========",alarmTime);
        return "闹钟设置为： " + alarmTime;
    }

}
